package com.parktech.sun.web.controller;

import com.parktech.sun.domain.model.Constants;
import com.parktech.sun.domain.repository.Page;
import com.parktech.sun.domain.service.industryservice.IndustryServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * User: Think
 * Date: 11-1-18
 * Time: 下午10:50
 */
@Controller
public class IndustryRequirementViewController {

    private int pageSize = Constants.PAGINATION_PAGE_SIZE;

    private IndustryServiceService industryServiceService;

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    @Autowired
    public IndustryRequirementViewController(IndustryServiceService industryServiceService) {
        this.industryServiceService = industryServiceService;
    }

    @RequestMapping("/industryrequirements/pages/{pageNo}")
    public String pageIndustryPolicy(@PathVariable("pageNo") int pageNo, Model model) {
        Page page = new Page(pageSize, pageNo);
        model.addAttribute(industryServiceService.pageByRequirement(page));
        return "industryrequirements";
    }

}
